package com.lpf.hotelsystem.controller;

import com.lpf.hotelsystem.pojo.CommentEntity;
import com.lpf.hotelsystem.service.impl.CommentEntityServiceImpl;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
import io.swagger.annotations.Api;

import javax.annotation.Resource;

/**
 * 评论实体表(CommentEntity)表控制层
 *
 * @author makejava
 * @since 2025-01-18 17:52:21
 */
@RestController
@RequestMapping("commentEntity")
@Api(value = "评论实体表(CommentEntity)",tags = "评论实体表(CommentEntity)接口API")
public class CommentEntityController {
    /**
     * 服务对象
     */
    @Resource
    private CommentEntityServiceImpl commentEntityServiceImpl;

    /**
     * 一次性全部查询
     *
     * @return 查询结果
     */
    @GetMapping("/selectAll")
    public Map<String, Object> selectAll() {

        return commentEntityServiceImpl.selectAll();
    }

    /**
     * 分页查询
     *
     * @param commentEntity 筛选条件
     * @param page        要查询第几页
     * @param limit       每页显示多少条
     * @return 查询结果
     */
    @GetMapping("/selectByLimit")
    public Map<String, Object> selectByLimit(CommentEntity commentEntity, @RequestParam int page, @RequestParam int limit) {
        return commentEntityServiceImpl.selectByLimit(commentEntity, page, limit);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/selectById")
    public Map<String, Object> selectById(@RequestParam Integer id) {
        return commentEntityServiceImpl.selectById(id);
    }

    /**
     * 新增数据
     *
     * @param commentEntity 实体
     * @return 新增结果
     */
    @PostMapping("/insert")
    public Map<String, Object> insert(@RequestBody CommentEntity commentEntity) {
        return commentEntityServiceImpl.insert(commentEntity);
    }

    /**
     * 编辑数据
     *
     * @param commentEntity 实体
     * @return 编辑结果
     */
    @PutMapping("/updateById")
    public Map<String, Object> updateById(@RequestBody CommentEntity commentEntity) {
        return commentEntityServiceImpl.updateById(commentEntity);
    }

    /**
     * 删除数据
     *
     * @param id 主键
     * @return 删除是否成功
     */
    @DeleteMapping("/deleteById")
    public Map<String, Object> deleteById(@RequestParam Integer commentId) {
        return commentEntityServiceImpl.deleteById(commentId);
    }

}

